package com.logistics.map.entity.domain;

import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.IdType;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;
import com.baomidou.mybatisplus.annotation.TableName;
import com.logistics.map.entity.model.MapComponentsSave;
import com.logistics.utils.tool.DateUtils;
import com.logistics.utils.tool.StringUtils;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * <p>
 * 
 * </p>
 *
 * @author zhiyu.fan
 * @since 2024-05-28
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("lgs_map_components")
public class MapComponents implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    private Integer mapId;

    private String clazz;

    private String color;

    private String uuid;

    private String label;

    private String size;

    private String type;

    private String locationArea;

    private BigDecimal x;

    private BigDecimal y;

    private String routeCode;

    private Integer containerId;

    private String agvType;

    private String remark;

    private String workshop;

    private String location;

    private String deviceId;

    private String locationWcCode;

    private Boolean locationLock;

    private Integer currentStratum;

    private BigDecimal locationHeight;

    private String zone;

    private String relayWcCode;

    private String containerType;

    private String createOrgCode;

    private String createDepCode;

    private String creator;

    private Date createTime;

    private String updater;

    private Date updateTime;

    @TableField(exist = false)
    private String name;

    public MapComponents(){}

    public MapComponents(MapComponentsSave save){
        this.id = save.getId();
        this.mapId = save.getMapId();
        this.clazz = save.getClazz();
        this.color = save.getColor();
        this.uuid = save.getUuid();
        this.label = save.getLabel();
        this.size = save.getSize();
        this.type = save.getType();
        this.x = StringUtils.isNotNull(save.getX()) ? new BigDecimal(save.getX()) : BigDecimal.ZERO;
        this.y = StringUtils.isNotNull(save.getX()) ? new BigDecimal(save.getY()) : BigDecimal.ZERO;
        this.routeCode = save.getRouteCode();
        this.containerId = save.getContainerId();
        this.agvType = save.getAgvType();
        this.remark = save.getRemark();
        this.workshop = save.getWorkshop();
        this.location = save.getLocation();
        this.zone = save.getZone();
        this.deviceId = save.getDeviceId();
        this.locationWcCode = save.getLocationWcCode();
        this.relayWcCode = save.getRelayWcCode();
        this.locationLock = save.getLocationLock();
        this.locationArea = save.getLocationArea();
        this.containerType = save.getContainerType();
        this.createDepCode = save.getCreateDepCode();
        this.createOrgCode = save.getCreateOrgCode();
        this.creator = save.getCreator();
        this.createTime = DateUtils.stringToDateFormat(save.getCreateTime(), DateUtils.YYYY_MM_DD_HH_MM_SS);
        this.updater = save.getUpdater();
        this.updateTime = DateUtils.stringToDateFormat(save.getUpdateTime(), DateUtils.YYYY_MM_DD_HH_MM_SS);
    }

    public static MapComponents build(MapComponentsSave save){
        return new MapComponents(save);
    }

    public static MapComponents build(String location){
        MapComponents mapComponents = new MapComponents();
        mapComponents.setLocation(location);
        return mapComponents;
    }

    public static MapComponents build(Integer currentStratum, BigDecimal location){
        MapComponents mapComponents = new MapComponents();
        mapComponents.setCurrentStratum(currentStratum);
        mapComponents.setLocationHeight(location);
        return mapComponents;
    }

    public static MapComponents build(boolean locationLock){
        MapComponents mapComponents = new MapComponents();
        mapComponents.setLocationLock(locationLock);
        return mapComponents;
    }

    public static MapComponents build(BigDecimal locationHeight, Integer currentStratum, boolean locationLock){
        MapComponents mapComponents = new MapComponents();
        mapComponents.setLocationHeight(locationHeight);
        mapComponents.setCurrentStratum(currentStratum);
        mapComponents.setLocationLock(locationLock);
        return mapComponents;
    }

    public static MapComponents build(BigDecimal x, BigDecimal y, Integer id){
        MapComponents mapComponents = new MapComponents();
        mapComponents.setX(x);
        mapComponents.setY(y);
        mapComponents.setId(id);
        return mapComponents;
    }
}
